﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatterns
{
    public class SinglePattern
    {
        public static SinglePattern Instance = null;

        private static readonly object _lock = new object();

        private SinglePattern()
        {
        }

        public static SinglePattern GetInstance(string value)
        {

            if (Instance == null)
            {

                lock (_lock)
                {
                    if (Instance == null)
                    {
                        Instance = new SinglePattern();
                        Instance.Value = value;
                    }
                }
            }


            return Instance;
        }

        public string Value { get; set; }
    }


    public class Singleton2
    {
        private static Singleton2 _Singleton2 = null;

        static Singleton2()
        {
            _Singleton2 = new Singleton2();
        }

        public static Singleton2 GetInstance()
        {
            return _Singleton2;
        }
    }
}
